//
//  LGSXorGate.m
//  LogicSim
//
//  Created by Jeremy Pereira on 06/04/2012.
//  Copyright (c) 2012 Jeremy PEreira. All rights reserved.
//

#import "LGSXorGate.h"
#import "LGSEdge.h"

#define XOR(A,B)	(((A) && !(B)) || ((B) && !(A)))

@implementation LGSXorGate

-(void) evaluateAffectedNodes: (NSMutableOrderedSet*) affectedNodes;
{
    bool a = [[self input: [[self class] inputAName]] value];
    bool b = [[self input: [[self class] inputBName]] value];
    bool result = XOR(a, b);
    NSSet* outputs = [self outputsForName: [[self class] outputName]];
    for (LGSEdge* anOutput in outputs)
    {
        [anOutput setValue: result affectedNodes: affectedNodes];
    }
}

@end
